#include<iostream>
#include<algorithm>
using namespace std;
int x1, y1, x2, y2;
const int N = 1e5 + 10;
struct node
{
    int x, y, d;
    //d为距离第一颗导弹的距离
}a[N];
int calc(int x1, int y1, int x, int y)
{
    int dx = x1 - x, dy = y1 - y;
    return dx * dx + dy * dy;
}
int main()
{
    cin >> x1 >> y1 >> x2 >> y2;
    int n; cin >> n;
    for (int i = 1; i <= n; i++)
    {
        int x, y; cin >> x >> y;
        a[i].x = x; a[i].y = y;
        a[i].d = calc(x1, y1, x, y);
    }

    sort(a + 1, a + 1 + n, [](node& x, node& y)
    {
        return x.d > y.d;
    });
    int ret = 0x3f3f3f3f, r2 = 0;
    for (int i = 2; i <= n + 1; i++)
    {
        int r1 = a[i].d;
        r2 = max(r2, calc(x2, y2, a[i - 1].x, a[i - 1].y));
        ret = min(ret, r1 + r2);
    }

    cout << ret << endl;
    return 0;
}